<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateProductsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('products', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('youzan_item_id')->default(0)->comment('有赞商品的唯一id');
			$table->string('name')->comment('商品的简称 显示在APP试戴商品列表位置');
			$table->string('title')->default('')->comment('商品的标题');
			$table->integer('asset_id')->unsigned()->default(0)->comment('素材ID');
			$table->string('description')->nullable()->comment('商品简介');
			$table->integer('customer_id')->default(0)->comment('属于的Customer，其他是代理customer上传的商品');
			$table->integer('store_id')->unsigned()->default(0)->comment('属于的Store，如不属于任何Store值为0');
			$table->integer('category_id')->default(0)->comment('对应主分类ID');
			$table->integer('brand_id')->default(0)->comment('品牌ID');
			$table->integer('brand_series_id')->default(0)->comment('品牌系列ID');
			$table->integer('cosmetic_material_id')->default(0)->comment('关联cosmetic_materials表的id');
			$table->integer('product_mod_id')->default(0)->comment('对应商品模型ID');
			$table->decimal('market_price', 10)->default(1000000.00)->comment('市场价');
			$table->decimal('sell_price', 10)->default(1000000.00)->comment('商品真实售价');
			$table->integer('stock')->unsigned()->default(0)->comment('商品当前库存');
			$table->text('taobao_product_info', 65535)->nullable()->comment('淘宝的商品信息 json格式');
			$table->string('taobao_url')->nullable()->comment('淘宝商品详情的链接url');
			$table->string('product_url')->nullable()->comment('商品外链的url');
			$table->integer('product_url_type_id')->default(0)->comment('关联product_url_types表的id');
			$table->string('spu_code')->default('')->comment('产品类目编码');
			$table->text('content', 65535)->nullable()->comment('富文本编辑的内容');
			$table->boolean('sex')->default(0)->comment('适用的性别：1 男 2 女 0 通用');
			$table->boolean('is_sale')->default(1)->comment('是否出售中 0：否，1：是');
			$table->boolean('is_deleted')->default(0)->comment('是否删除了，0：否， 1：是');
			$table->boolean('is_new')->default(1)->comment('是否是新品 0：否，1：是');
			$table->boolean('is_hot')->default(0)->comment('是否热销  0：否，1：是');
			$table->integer('priority')->default(0)->comment('优先级 0-10000，越大越靠前');
			$table->integer('try_on')->unsigned()->default(0)->comment('试戴次数');
			$table->timestamps();
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('products');
	}

}
